
// License Notification
//======================================================
// Copyright (c) 2010 Channel Intelligence Inc.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// ======================================================


using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Reflection;
using MongoDB.Bson;
using CIP4.Common;
using CIP4.Simple;
using CIP4.Item;

namespace CIP4.Serializer
{


    public class CIP4_Simple_SerializerBaseType : SerializerBaseType
    {
        public static object DeSerializeFromXElement(string typeName, XElement element)
        {
            switch (typeName)
            {

                case "CIP4ConnectionItemType":
                    return CIP4ConnectionItemType_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4ConnectionAttribute":
                    return CIP4ConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4SqlConnectionAttribute":
                    return CIP4SqlConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4MySqlConnectionAttribute":
                    return CIP4MySqlConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4MossoConnectionAttribute":
                    return CIP4MossoConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4S3ConnectionAttribute":
                    return CIP4S3ConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4XmlFileConnectionAttribute":
                    return CIP4XmlFileConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4FileConnectionAttribute":
                    return CIP4FileConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4DictionaryConnectionAttribute":
                    return CIP4DictionaryConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4CassandraConnectionAttribute":
                    return CIP4CassandraConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4MongoDBConnectionAttribute":
                    return CIP4MongoDBConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4MigratorConnectionAttribute":
                    return CIP4MigratorConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4MultiThreadConnectionAttribute":
                    return CIP4MultiThreadConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4MassTransitConnectionAttribute":
                    return CIP4MassTransitConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4SliceConnectionAttribute":
                    return CIP4SliceConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4GenericSliceConnectionAttribute":
                    return CIP4GenericSliceConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4MongoDBSliceConnectionAttribute":
                    return CIP4MongoDBSliceConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "CIP4TemplateConnectionAttribute":
                    return CIP4TemplateConnectionAttribute_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                case "ViewType":
                    return ViewType_Serializer.SetProperties(DateTime.Now, null, element, null, null);

                default:
                    return ValueFromString(typeName, element.Value);
            }
        }

        public static void SerializeToXml(string typeName, object value, string keyValue, XmlTextWriter xwrtr)
        {
            switch (typeName)
            {

                case "CIP4ConnectionItemType":
                    CIP4ConnectionItemType_Serializer.Serialize((CIP4.Simple.CIP4ConnectionItemType)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4ConnectionAttribute":
                    CIP4ConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4ConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4SqlConnectionAttribute":
                    CIP4SqlConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4SqlConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4MySqlConnectionAttribute":
                    CIP4MySqlConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MySqlConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4MossoConnectionAttribute":
                    CIP4MossoConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MossoConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4S3ConnectionAttribute":
                    CIP4S3ConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4S3ConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4XmlFileConnectionAttribute":
                    CIP4XmlFileConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4XmlFileConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4FileConnectionAttribute":
                    CIP4FileConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4FileConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4DictionaryConnectionAttribute":
                    CIP4DictionaryConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4DictionaryConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4CassandraConnectionAttribute":
                    CIP4CassandraConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4CassandraConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4MongoDBConnectionAttribute":
                    CIP4MongoDBConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MongoDBConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4MigratorConnectionAttribute":
                    CIP4MigratorConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MigratorConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4MultiThreadConnectionAttribute":
                    CIP4MultiThreadConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MultiThreadConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4MassTransitConnectionAttribute":
                    CIP4MassTransitConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MassTransitConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4SliceConnectionAttribute":
                    CIP4SliceConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4SliceConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4GenericSliceConnectionAttribute":
                    CIP4GenericSliceConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4GenericSliceConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4MongoDBSliceConnectionAttribute":
                    CIP4MongoDBSliceConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "CIP4TemplateConnectionAttribute":
                    CIP4TemplateConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4TemplateConnectionAttribute)value, keyValue, xwrtr, null, null, null, false);
                    break;

                case "ViewType":
                    ViewType_Serializer.Serialize((CIP4.Simple.ViewType)value, keyValue, xwrtr, null, null, null, false);
                    break;

                default:
                    XmlValueFromObject(typeName, value, keyValue, xwrtr);
                    break;
            }
        }
    }


    public class CIP4ConnectionItemType_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {
                    new KeyValuePair<string, int>("Name", 0),

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4ConnectionItemType item)
        {
            if (item == null)
                return null;
            if (index == 0)
                switch (path[0])
                {
                    case "ExternalID":
                        return GetExternalIDForObject(item);
                }



            switch (path[index])
            {
                case "Connection":
                    return CIP4.Serializer.CIP4ConnectionAttribute_Serializer.GetValueForPath(path, index + 1, item.Connection);
                case "Name":
                    return item.Name;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static ExternalIDType GetExternalID(XElement itemElement)
        {
            XElement element = null;
            if (itemElement.Name == XName.Get("Item", Globals.ciiNS))
            {
                element = itemElement.LastElement();
            }
            else
                element = itemElement;
            List<object> parts = new List<object>();
            parts.Add(StringValue(element.Element(XName.Get("String", Globals.cioNS)), string.Empty));


            ExternalIDType result = ExternalIDType.ExternalIDFromParts(parts);

            if (result == null)
                return ExternalIDType.ExternalIDFromEscapedString(StringValue(itemElement.Element(XName.Get("ExternalID", Globals.ciiNS)), string.Empty));

            return result;
        }
        public static ExternalIDType GetExternalIDForObject(CIP4.Simple.CIP4ConnectionItemType value)
        {
            List<object> parts = new List<object>();
            parts.Add(value.Name);

            return ExternalIDType.ExternalIDFromParts(parts);
        }

        public static CIP4.Simple.CIP4ConnectionItemType DeSerialize(DateTime versionTimestamp, object itemData, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {
            return DeSerialize(versionTimestamp, itemData, StreamSeeds, propertyPath, null);
        }
        public static CIP4.Simple.CIP4ConnectionItemType DeSerialize(DateTime versionTimestamp, object itemData, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4ConnectionItemType defaultValue)
        {
            XElement itemElement = GetXmlData(itemData);
            if (itemElement == null)
                return defaultValue;
            XElement element = null;
            if (itemElement.Name == XName.Get("Item", Globals.ciiNS))
            {
                element = itemElement.LastElement();
                propertyPath = "CIP4.Simple.CIP4ConnectionItemType";
            }
            else
                element = itemElement;


            if (element.Name.LocalName != "CIP4ConnectionItemType")
                return null;


            CIP4.Simple.CIP4ConnectionItemType objectValue = SetProperties(versionTimestamp, itemElement, element, StreamSeeds, propertyPath);
    

            // no version handling for this type
            return objectValue == null? defaultValue : (CIP4.Simple.CIP4ConnectionItemType)objectValue;
        }

        public static CIP4.Simple.CIP4ConnectionItemType SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4ConnectionItemType objectValue = new CIP4.Simple.CIP4ConnectionItemType();
                objectValue.Name = StringValue(GetExternalIDFromElements("Name", element, itemElement, GetExternalID), objectValue.Name);
                objectValue.Connection = CIP4.Serializer.CIP4ConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element.Element(XName.Get("Connection", Globals.cioNS)).FirstElement(), StreamSeeds, propertyPath + ".Connection", objectValue.Connection);
 
;

            return (CIP4.Simple.CIP4ConnectionItemType)objectValue;
        }

        public static CIP4.Simple.CIP4ConnectionItemType GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4ConnectionItemType previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4ConnectionItemType GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4ConnectionItemType  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4ConnectionItemType objectValue = new CIP4.Simple.CIP4ConnectionItemType();

            if (Values.ContainsKey("Name"))
                objectValue.Name = StringValue(Values["Name"].ToString(), objectValue.Name);
            else
                objectValue.Name = previousVersion.Name; 
;

            return (CIP4.Simple.CIP4ConnectionItemType)objectValue;
        }


        internal static List<CIP4.Simple.CIP4ConnectionItemType> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4ConnectionItemType> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4ConnectionItemType> list = new List<CIP4.Simple.CIP4ConnectionItemType>();
            int index = 0;
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath + "[" + (index++).ToString() + "]", null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath + "[" + getKey(valueElement.Attribute("Key").Value) + "]", null));
            return dictionary;
        }

        public static List<CIP4ReferenceType<CIP4.Simple.CIP4ConnectionItemType>> DeSerializeReferenceList(XElement element)
        {
            if (element == null)
                return null;
            List<CIP4ReferenceType<CIP4.Simple.CIP4ConnectionItemType>> list = new List<CIP4ReferenceType<CIP4.Simple.CIP4ConnectionItemType>>();
            foreach (XElement valueElement in element.Elements())
            {
                CIP4ReferenceType<CIP4.Simple.CIP4ConnectionItemType> refValue = new CIP4ReferenceType<CIP4.Simple.CIP4ConnectionItemType>();
                refValue.TargetExternalID = GetExternalIdFromReferenceElement(valueElement);
                list.Add(refValue);
            }
            return list;
        }

        public static CIP4ReferenceType<CIP4.Simple.CIP4ConnectionItemType> MakeCIP4Reference(XElement element, CIP4ReferenceType<CIP4.Simple.CIP4ConnectionItemType> defaultValue)
        {
            string externalID = GetExternalIdFromReferenceElement(element);
            if (!string.IsNullOrEmpty(externalID))
                return new CIP4ReferenceType<CIP4.Simple.CIP4ConnectionItemType> { TargetExternalID = externalID };
            else
                return defaultValue;
        }

        public static string SerializeItem(CIP4.Simple.CIP4ConnectionItemType value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {



            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            xwrtr.WriteStartElement("Item", Globals.ciiNS);
            xwrtr.WriteElementString("Valid", "1");
            xwrtr.WriteElementString("ItemStatus", "100");
            xwrtr.WriteElementString("ExternalID", GetExternalIDForObject(value).ToString());
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4ConnectionItemType", serializerWrapper, true);
            xwrtr.WriteEndElement();
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4ConnectionItemType value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4ConnectionItemType", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.Connection != null)
            {
                xwrtr.WriteStartElement("Connection");
                CIP4ConnectionAttribute_Serializer.Serialize(value.Connection, null, xwrtr, StreamSeeds, propertyPath + ".Connection", serializerWrapper, doVersioning);
                xwrtr.WriteEndElement();
            }
            if (value.Name != default(System.String))
            {
                xwrtr.WriteStartElement("Name");
                xwrtr.WriteElementString("String", value.Name);
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4ConnectionItemType)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4ConnectionItemType>
        {
            public bool Equals(CIP4.Simple.CIP4ConnectionItemType x, CIP4.Simple.CIP4ConnectionItemType y)
            {
                return GetExternalIDForObject(x).ToString() == GetExternalIDForObject(y).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4ConnectionItemType obj)
            {
                return GetExternalIDForObject(obj).ToString().GetHashCode();
            }
        }

    }

    public class CIP4ConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4ConnectionAttribute item)
        {
            if (item == null)
                return null;

            if (item is CIP4.Simple.CIP4SqlConnectionAttribute)
                return CIP4SqlConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4SqlConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4MySqlConnectionAttribute)
                return CIP4MySqlConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4MySqlConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4MossoConnectionAttribute)
                return CIP4MossoConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4MossoConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4S3ConnectionAttribute)
                return CIP4S3ConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4S3ConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4XmlFileConnectionAttribute)
                return CIP4XmlFileConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4XmlFileConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4FileConnectionAttribute)
                return CIP4FileConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4FileConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4DictionaryConnectionAttribute)
                return CIP4DictionaryConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4DictionaryConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4CassandraConnectionAttribute)
                return CIP4CassandraConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4CassandraConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4MongoDBConnectionAttribute)
                return CIP4MongoDBConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4MongoDBConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4MigratorConnectionAttribute)
                return CIP4MigratorConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4MigratorConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4MultiThreadConnectionAttribute)
                return CIP4MultiThreadConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4MultiThreadConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4MassTransitConnectionAttribute)
                return CIP4MassTransitConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4MassTransitConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4SliceConnectionAttribute)
                return CIP4SliceConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4SliceConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4GenericSliceConnectionAttribute)
                return CIP4GenericSliceConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4GenericSliceConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)
                return CIP4MongoDBSliceConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4TemplateConnectionAttribute)
                return CIP4TemplateConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4TemplateConnectionAttribute)item);

            switch (path[index])
            {
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4ConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4ConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName == "CIP4SqlConnectionAttribute")
                return CIP4SqlConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4MySqlConnectionAttribute")
                return CIP4MySqlConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4MossoConnectionAttribute")
                return CIP4MossoConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4S3ConnectionAttribute")
                return CIP4S3ConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4XmlFileConnectionAttribute")
                return CIP4XmlFileConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4FileConnectionAttribute")
                return CIP4FileConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4DictionaryConnectionAttribute")
                return CIP4DictionaryConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4CassandraConnectionAttribute")
                return CIP4CassandraConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4MongoDBConnectionAttribute")
                return CIP4MongoDBConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4MigratorConnectionAttribute")
                return CIP4MigratorConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4MultiThreadConnectionAttribute")
                return CIP4MultiThreadConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4MassTransitConnectionAttribute")
                return CIP4MassTransitConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4SliceConnectionAttribute")
                return CIP4SliceConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4GenericSliceConnectionAttribute")
                return CIP4GenericSliceConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4MongoDBSliceConnectionAttribute")
                return CIP4MongoDBSliceConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4TemplateConnectionAttribute")
                return CIP4TemplateConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName != "CIP4ConnectionAttribute")
                return null;

            object objectValue = null;
     
            // no version handling for this type           
            return (CIP4.Simple.CIP4ConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4ConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {

            object objectValue = null;
            return (CIP4.Simple.CIP4ConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4ConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4ConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4ConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4ConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {
            object objectValue = null;
            return (CIP4.Simple.CIP4ConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4ConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4ConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4ConnectionAttribute> list = new List<CIP4.Simple.CIP4ConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4ConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4ConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4ConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {
            if (value is CIP4.Simple.CIP4SqlConnectionAttribute)
            {
                CIP4SqlConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4SqlConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4MySqlConnectionAttribute)
            {
                CIP4MySqlConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MySqlConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4MossoConnectionAttribute)
            {
                CIP4MossoConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MossoConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4S3ConnectionAttribute)
            {
                CIP4S3ConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4S3ConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4XmlFileConnectionAttribute)
            {
                CIP4XmlFileConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4XmlFileConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4FileConnectionAttribute)
            {
                CIP4FileConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4FileConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4DictionaryConnectionAttribute)
            {
                CIP4DictionaryConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4DictionaryConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4CassandraConnectionAttribute)
            {
                CIP4CassandraConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4CassandraConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4MongoDBConnectionAttribute)
            {
                CIP4MongoDBConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MongoDBConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4MigratorConnectionAttribute)
            {
                CIP4MigratorConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MigratorConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4MultiThreadConnectionAttribute)
            {
                CIP4MultiThreadConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MultiThreadConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4MassTransitConnectionAttribute)
            {
                CIP4MassTransitConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MassTransitConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4SliceConnectionAttribute)
            {
                CIP4SliceConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4SliceConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4GenericSliceConnectionAttribute)
            {
                CIP4GenericSliceConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4GenericSliceConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)
            {
                CIP4MongoDBSliceConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4TemplateConnectionAttribute)
            {
                CIP4TemplateConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4TemplateConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }

            xwrtr.WriteStartElement("CIP4ConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4ConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4ConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4ConnectionAttribute x, CIP4.Simple.CIP4ConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4ConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4SqlConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4SqlConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "ApplicationName":
                    return item.ApplicationName;
                case "Database":
                    return item.Database;
                case "Host":
                    return item.Host;
                case "Password":
                    return item.Password;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;
                case "UserId":
                    return item.UserId;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4SqlConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4SqlConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4SqlConnectionAttribute")
                return null;


            CIP4.Simple.CIP4SqlConnectionAttribute objectValue = new CIP4.Simple.CIP4SqlConnectionAttribute();
                objectValue.Database = StringValue(element.Element(XName.Get("Database", Globals.cioNS)), objectValue.Database);
                objectValue.Host = StringValue(element.Element(XName.Get("Host", Globals.cioNS)), objectValue.Host);
                objectValue.UserId = StringValue(element.Element(XName.Get("UserId", Globals.cioNS)), objectValue.UserId);
                objectValue.Password = StringValue(element.Element(XName.Get("Password", Globals.cioNS)), objectValue.Password);
                objectValue.ApplicationName = StringValue(element.Element(XName.Get("ApplicationName", Globals.cioNS)), objectValue.ApplicationName);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4SqlConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4SqlConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4SqlConnectionAttribute objectValue = new CIP4.Simple.CIP4SqlConnectionAttribute();
                objectValue.Database = StringValue(element.Element(XName.Get("Database", Globals.cioNS)), objectValue.Database);
                objectValue.Host = StringValue(element.Element(XName.Get("Host", Globals.cioNS)), objectValue.Host);
                objectValue.UserId = StringValue(element.Element(XName.Get("UserId", Globals.cioNS)), objectValue.UserId);
                objectValue.Password = StringValue(element.Element(XName.Get("Password", Globals.cioNS)), objectValue.Password);
                objectValue.ApplicationName = StringValue(element.Element(XName.Get("ApplicationName", Globals.cioNS)), objectValue.ApplicationName);
 
;

            return (CIP4.Simple.CIP4SqlConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4SqlConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4SqlConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4SqlConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4SqlConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4SqlConnectionAttribute objectValue = new CIP4.Simple.CIP4SqlConnectionAttribute();

            if (Values.ContainsKey("Database"))
                objectValue.Database = StringValue(Values["Database"].ToString(), objectValue.Database);
            else
                objectValue.Database = previousVersion.Database;
            if (Values.ContainsKey("Host"))
                objectValue.Host = StringValue(Values["Host"].ToString(), objectValue.Host);
            else
                objectValue.Host = previousVersion.Host;
            if (Values.ContainsKey("UserId"))
                objectValue.UserId = StringValue(Values["UserId"].ToString(), objectValue.UserId);
            else
                objectValue.UserId = previousVersion.UserId;
            if (Values.ContainsKey("Password"))
                objectValue.Password = StringValue(Values["Password"].ToString(), objectValue.Password);
            else
                objectValue.Password = previousVersion.Password;
            if (Values.ContainsKey("ApplicationName"))
                objectValue.ApplicationName = StringValue(Values["ApplicationName"].ToString(), objectValue.ApplicationName);
            else
                objectValue.ApplicationName = previousVersion.ApplicationName; 
;

            return (CIP4.Simple.CIP4SqlConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4SqlConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4SqlConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4SqlConnectionAttribute> list = new List<CIP4.Simple.CIP4SqlConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4SqlConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4SqlConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4SqlConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4SqlConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.ApplicationName != default(System.String))
            {
                xwrtr.WriteStartElement("ApplicationName");
                xwrtr.WriteElementString("String", value.ApplicationName);
                xwrtr.WriteEndElement();
            }

            if (value.Database != default(System.String))
            {
                xwrtr.WriteStartElement("Database");
                xwrtr.WriteElementString("String", value.Database);
                xwrtr.WriteEndElement();
            }

            if (value.Host != default(System.String))
            {
                xwrtr.WriteStartElement("Host");
                xwrtr.WriteElementString("String", value.Host);
                xwrtr.WriteEndElement();
            }

            if (value.Password != default(System.String))
            {
                xwrtr.WriteStartElement("Password");
                xwrtr.WriteElementString("String", value.Password);
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.UserId != default(System.String))
            {
                xwrtr.WriteStartElement("UserId");
                xwrtr.WriteElementString("String", value.UserId);
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4SqlConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4SqlConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4SqlConnectionAttribute x, CIP4.Simple.CIP4SqlConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4SqlConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4MySqlConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4MySqlConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "Database":
                    return item.Database;
                case "Host":
                    return item.Host;
                case "Password":
                    return item.Password;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;
                case "UserId":
                    return item.UserId;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4MySqlConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4MySqlConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4MySqlConnectionAttribute")
                return null;


            CIP4.Simple.CIP4MySqlConnectionAttribute objectValue = new CIP4.Simple.CIP4MySqlConnectionAttribute();
                objectValue.Database = StringValue(element.Element(XName.Get("Database", Globals.cioNS)), objectValue.Database);
                objectValue.Host = StringValue(element.Element(XName.Get("Host", Globals.cioNS)), objectValue.Host);
                objectValue.UserId = StringValue(element.Element(XName.Get("UserId", Globals.cioNS)), objectValue.UserId);
                objectValue.Password = StringValue(element.Element(XName.Get("Password", Globals.cioNS)), objectValue.Password);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4MySqlConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MySqlConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4MySqlConnectionAttribute objectValue = new CIP4.Simple.CIP4MySqlConnectionAttribute();
                objectValue.Database = StringValue(element.Element(XName.Get("Database", Globals.cioNS)), objectValue.Database);
                objectValue.Host = StringValue(element.Element(XName.Get("Host", Globals.cioNS)), objectValue.Host);
                objectValue.UserId = StringValue(element.Element(XName.Get("UserId", Globals.cioNS)), objectValue.UserId);
                objectValue.Password = StringValue(element.Element(XName.Get("Password", Globals.cioNS)), objectValue.Password);
 
;

            return (CIP4.Simple.CIP4MySqlConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MySqlConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MySqlConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4MySqlConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MySqlConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4MySqlConnectionAttribute objectValue = new CIP4.Simple.CIP4MySqlConnectionAttribute();

            if (Values.ContainsKey("Database"))
                objectValue.Database = StringValue(Values["Database"].ToString(), objectValue.Database);
            else
                objectValue.Database = previousVersion.Database;
            if (Values.ContainsKey("Host"))
                objectValue.Host = StringValue(Values["Host"].ToString(), objectValue.Host);
            else
                objectValue.Host = previousVersion.Host;
            if (Values.ContainsKey("UserId"))
                objectValue.UserId = StringValue(Values["UserId"].ToString(), objectValue.UserId);
            else
                objectValue.UserId = previousVersion.UserId;
            if (Values.ContainsKey("Password"))
                objectValue.Password = StringValue(Values["Password"].ToString(), objectValue.Password);
            else
                objectValue.Password = previousVersion.Password; 
;

            return (CIP4.Simple.CIP4MySqlConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4MySqlConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4MySqlConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4MySqlConnectionAttribute> list = new List<CIP4.Simple.CIP4MySqlConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4MySqlConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4MySqlConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4MySqlConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4MySqlConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.Database != default(System.String))
            {
                xwrtr.WriteStartElement("Database");
                xwrtr.WriteElementString("String", value.Database);
                xwrtr.WriteEndElement();
            }

            if (value.Host != default(System.String))
            {
                xwrtr.WriteStartElement("Host");
                xwrtr.WriteElementString("String", value.Host);
                xwrtr.WriteEndElement();
            }

            if (value.Password != default(System.String))
            {
                xwrtr.WriteStartElement("Password");
                xwrtr.WriteElementString("String", value.Password);
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.UserId != default(System.String))
            {
                xwrtr.WriteStartElement("UserId");
                xwrtr.WriteElementString("String", value.UserId);
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4MySqlConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4MySqlConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4MySqlConnectionAttribute x, CIP4.Simple.CIP4MySqlConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4MySqlConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4MossoConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4MossoConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "AccessKey":
                    return item.AccessKey;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;
                case "UserName":
                    return item.UserName;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4MossoConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4MossoConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4MossoConnectionAttribute")
                return null;


            CIP4.Simple.CIP4MossoConnectionAttribute objectValue = new CIP4.Simple.CIP4MossoConnectionAttribute();
                objectValue.UserName = StringValue(element.Element(XName.Get("UserName", Globals.cioNS)), objectValue.UserName);
                objectValue.AccessKey = StringValue(element.Element(XName.Get("AccessKey", Globals.cioNS)), objectValue.AccessKey);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4MossoConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MossoConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4MossoConnectionAttribute objectValue = new CIP4.Simple.CIP4MossoConnectionAttribute();
                objectValue.UserName = StringValue(element.Element(XName.Get("UserName", Globals.cioNS)), objectValue.UserName);
                objectValue.AccessKey = StringValue(element.Element(XName.Get("AccessKey", Globals.cioNS)), objectValue.AccessKey);
 
;

            return (CIP4.Simple.CIP4MossoConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MossoConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MossoConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4MossoConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MossoConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4MossoConnectionAttribute objectValue = new CIP4.Simple.CIP4MossoConnectionAttribute();

            if (Values.ContainsKey("UserName"))
                objectValue.UserName = StringValue(Values["UserName"].ToString(), objectValue.UserName);
            else
                objectValue.UserName = previousVersion.UserName;
            if (Values.ContainsKey("AccessKey"))
                objectValue.AccessKey = StringValue(Values["AccessKey"].ToString(), objectValue.AccessKey);
            else
                objectValue.AccessKey = previousVersion.AccessKey; 
;

            return (CIP4.Simple.CIP4MossoConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4MossoConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4MossoConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4MossoConnectionAttribute> list = new List<CIP4.Simple.CIP4MossoConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4MossoConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4MossoConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4MossoConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4MossoConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.AccessKey != default(System.String))
            {
                xwrtr.WriteStartElement("AccessKey");
                xwrtr.WriteElementString("String", value.AccessKey);
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.UserName != default(System.String))
            {
                xwrtr.WriteStartElement("UserName");
                xwrtr.WriteElementString("String", value.UserName);
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4MossoConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4MossoConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4MossoConnectionAttribute x, CIP4.Simple.CIP4MossoConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4MossoConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4S3ConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4S3ConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "AccessKey":
                    return item.AccessKey;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SecretKey":
                    return item.SecretKey;
                case "SerializerKind":
                    return item.SerializerKind;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4S3ConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4S3ConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4S3ConnectionAttribute")
                return null;


            CIP4.Simple.CIP4S3ConnectionAttribute objectValue = new CIP4.Simple.CIP4S3ConnectionAttribute();
                objectValue.AccessKey = StringValue(element.Element(XName.Get("AccessKey", Globals.cioNS)), objectValue.AccessKey);
                objectValue.SecretKey = StringValue(element.Element(XName.Get("SecretKey", Globals.cioNS)), objectValue.SecretKey);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4S3ConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4S3ConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4S3ConnectionAttribute objectValue = new CIP4.Simple.CIP4S3ConnectionAttribute();
                objectValue.AccessKey = StringValue(element.Element(XName.Get("AccessKey", Globals.cioNS)), objectValue.AccessKey);
                objectValue.SecretKey = StringValue(element.Element(XName.Get("SecretKey", Globals.cioNS)), objectValue.SecretKey);
 
;

            return (CIP4.Simple.CIP4S3ConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4S3ConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4S3ConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4S3ConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4S3ConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4S3ConnectionAttribute objectValue = new CIP4.Simple.CIP4S3ConnectionAttribute();

            if (Values.ContainsKey("AccessKey"))
                objectValue.AccessKey = StringValue(Values["AccessKey"].ToString(), objectValue.AccessKey);
            else
                objectValue.AccessKey = previousVersion.AccessKey;
            if (Values.ContainsKey("SecretKey"))
                objectValue.SecretKey = StringValue(Values["SecretKey"].ToString(), objectValue.SecretKey);
            else
                objectValue.SecretKey = previousVersion.SecretKey; 
;

            return (CIP4.Simple.CIP4S3ConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4S3ConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4S3ConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4S3ConnectionAttribute> list = new List<CIP4.Simple.CIP4S3ConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4S3ConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4S3ConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4S3ConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4S3ConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.AccessKey != default(System.String))
            {
                xwrtr.WriteStartElement("AccessKey");
                xwrtr.WriteElementString("String", value.AccessKey);
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SecretKey != default(System.String))
            {
                xwrtr.WriteStartElement("SecretKey");
                xwrtr.WriteElementString("String", value.SecretKey);
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4S3ConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4S3ConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4S3ConnectionAttribute x, CIP4.Simple.CIP4S3ConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4S3ConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4XmlFileConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4XmlFileConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;
                case "XmlFileName":
                    return item.XmlFileName;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4XmlFileConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4XmlFileConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4XmlFileConnectionAttribute")
                return null;


            CIP4.Simple.CIP4XmlFileConnectionAttribute objectValue = new CIP4.Simple.CIP4XmlFileConnectionAttribute();
                objectValue.XmlFileName = StringValue(element.Element(XName.Get("XmlFileName", Globals.cioNS)), objectValue.XmlFileName);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4XmlFileConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4XmlFileConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4XmlFileConnectionAttribute objectValue = new CIP4.Simple.CIP4XmlFileConnectionAttribute();
                objectValue.XmlFileName = StringValue(element.Element(XName.Get("XmlFileName", Globals.cioNS)), objectValue.XmlFileName);
 
;

            return (CIP4.Simple.CIP4XmlFileConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4XmlFileConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4XmlFileConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4XmlFileConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4XmlFileConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4XmlFileConnectionAttribute objectValue = new CIP4.Simple.CIP4XmlFileConnectionAttribute();

            if (Values.ContainsKey("XmlFileName"))
                objectValue.XmlFileName = StringValue(Values["XmlFileName"].ToString(), objectValue.XmlFileName);
            else
                objectValue.XmlFileName = previousVersion.XmlFileName; 
;

            return (CIP4.Simple.CIP4XmlFileConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4XmlFileConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4XmlFileConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4XmlFileConnectionAttribute> list = new List<CIP4.Simple.CIP4XmlFileConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4XmlFileConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4XmlFileConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4XmlFileConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4XmlFileConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.XmlFileName != default(System.String))
            {
                xwrtr.WriteStartElement("XmlFileName");
                xwrtr.WriteElementString("String", value.XmlFileName);
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4XmlFileConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4XmlFileConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4XmlFileConnectionAttribute x, CIP4.Simple.CIP4XmlFileConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4XmlFileConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4FileConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4FileConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "BaseDirectoryPath":
                    return item.BaseDirectoryPath;
                case "CompressData":
                    return item.CompressData;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4FileConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4FileConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4FileConnectionAttribute")
                return null;


            CIP4.Simple.CIP4FileConnectionAttribute objectValue = new CIP4.Simple.CIP4FileConnectionAttribute();
                objectValue.BaseDirectoryPath = StringValue(element.Element(XName.Get("BaseDirectoryPath", Globals.cioNS)), objectValue.BaseDirectoryPath);
                objectValue.CompressData = BooleanValue(element.Element(XName.Get("CompressData", Globals.cioNS)), objectValue.CompressData);
                objectValue.SerializerKind = (CIP4.Common.SerializerKindEnum)GetEnum(element.Element(XName.Get("SerializerKind", Globals.cioNS)), typeof(CIP4.Common.SerializerKindEnum), objectValue.SerializerKind);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4FileConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4FileConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4FileConnectionAttribute objectValue = new CIP4.Simple.CIP4FileConnectionAttribute();
                objectValue.BaseDirectoryPath = StringValue(element.Element(XName.Get("BaseDirectoryPath", Globals.cioNS)), objectValue.BaseDirectoryPath);
                objectValue.CompressData = BooleanValue(element.Element(XName.Get("CompressData", Globals.cioNS)), objectValue.CompressData);
                objectValue.SerializerKind = (CIP4.Common.SerializerKindEnum)GetEnum(element.Element(XName.Get("SerializerKind", Globals.cioNS)), typeof(CIP4.Common.SerializerKindEnum), objectValue.SerializerKind);
 
;

            return (CIP4.Simple.CIP4FileConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4FileConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4FileConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4FileConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4FileConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4FileConnectionAttribute objectValue = new CIP4.Simple.CIP4FileConnectionAttribute();

            if (Values.ContainsKey("BaseDirectoryPath"))
                objectValue.BaseDirectoryPath = StringValue(Values["BaseDirectoryPath"].ToString(), objectValue.BaseDirectoryPath);
            else
                objectValue.BaseDirectoryPath = previousVersion.BaseDirectoryPath;
            if (Values.ContainsKey("CompressData"))
                objectValue.CompressData = BooleanValue(Values["CompressData"].ToString(), objectValue.CompressData);
            else
                objectValue.CompressData = previousVersion.CompressData;
            if (Values.ContainsKey("SerializerKind"))
                objectValue.SerializerKind = (CIP4.Common.SerializerKindEnum)GetEnum(Values["SerializerKind"].ToString(), typeof(CIP4.Common.SerializerKindEnum), objectValue.SerializerKind);
            else
                objectValue.SerializerKind = previousVersion.SerializerKind; 
;

            return (CIP4.Simple.CIP4FileConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4FileConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4FileConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4FileConnectionAttribute> list = new List<CIP4.Simple.CIP4FileConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4FileConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4FileConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4FileConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4FileConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.BaseDirectoryPath != default(System.String))
            {
                xwrtr.WriteStartElement("BaseDirectoryPath");
                xwrtr.WriteElementString("String", value.BaseDirectoryPath);
                xwrtr.WriteEndElement();
            }

            if (value.CompressData != default(System.Boolean))
            {
                xwrtr.WriteStartElement("CompressData");
                xwrtr.WriteElementString("Boolean", value.CompressData.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4FileConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4FileConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4FileConnectionAttribute x, CIP4.Simple.CIP4FileConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4FileConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4DictionaryConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4DictionaryConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "BaseDirectoryPath":
                    return item.BaseDirectoryPath;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;
                case "Temporary":
                    return item.Temporary;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4DictionaryConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4DictionaryConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4DictionaryConnectionAttribute")
                return null;


            CIP4.Simple.CIP4DictionaryConnectionAttribute objectValue = new CIP4.Simple.CIP4DictionaryConnectionAttribute();
                objectValue.BaseDirectoryPath = StringValue(element.Element(XName.Get("BaseDirectoryPath", Globals.cioNS)), objectValue.BaseDirectoryPath);
                objectValue.Temporary = BooleanValue(element.Element(XName.Get("Temporary", Globals.cioNS)), objectValue.Temporary);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4DictionaryConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4DictionaryConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4DictionaryConnectionAttribute objectValue = new CIP4.Simple.CIP4DictionaryConnectionAttribute();
                objectValue.BaseDirectoryPath = StringValue(element.Element(XName.Get("BaseDirectoryPath", Globals.cioNS)), objectValue.BaseDirectoryPath);
                objectValue.Temporary = BooleanValue(element.Element(XName.Get("Temporary", Globals.cioNS)), objectValue.Temporary);
 
;

            return (CIP4.Simple.CIP4DictionaryConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4DictionaryConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4DictionaryConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4DictionaryConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4DictionaryConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4DictionaryConnectionAttribute objectValue = new CIP4.Simple.CIP4DictionaryConnectionAttribute();

            if (Values.ContainsKey("BaseDirectoryPath"))
                objectValue.BaseDirectoryPath = StringValue(Values["BaseDirectoryPath"].ToString(), objectValue.BaseDirectoryPath);
            else
                objectValue.BaseDirectoryPath = previousVersion.BaseDirectoryPath;
            if (Values.ContainsKey("Temporary"))
                objectValue.Temporary = BooleanValue(Values["Temporary"].ToString(), objectValue.Temporary);
            else
                objectValue.Temporary = previousVersion.Temporary; 
;

            return (CIP4.Simple.CIP4DictionaryConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4DictionaryConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4DictionaryConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4DictionaryConnectionAttribute> list = new List<CIP4.Simple.CIP4DictionaryConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4DictionaryConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4DictionaryConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4DictionaryConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4DictionaryConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.BaseDirectoryPath != default(System.String))
            {
                xwrtr.WriteStartElement("BaseDirectoryPath");
                xwrtr.WriteElementString("String", value.BaseDirectoryPath);
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.Temporary != default(System.Boolean))
            {
                xwrtr.WriteStartElement("Temporary");
                xwrtr.WriteElementString("Boolean", value.Temporary.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4DictionaryConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4DictionaryConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4DictionaryConnectionAttribute x, CIP4.Simple.CIP4DictionaryConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4DictionaryConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4CassandraConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4CassandraConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "ColumnFamily":
                    return item.ColumnFamily;
                case "Keyspace":
                    return item.Keyspace;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4CassandraConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4CassandraConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4CassandraConnectionAttribute")
                return null;


            CIP4.Simple.CIP4CassandraConnectionAttribute objectValue = new CIP4.Simple.CIP4CassandraConnectionAttribute();
                objectValue.Keyspace = StringValue(element.Element(XName.Get("Keyspace", Globals.cioNS)), objectValue.Keyspace);
                objectValue.ColumnFamily = StringValue(element.Element(XName.Get("ColumnFamily", Globals.cioNS)), objectValue.ColumnFamily);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4CassandraConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4CassandraConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4CassandraConnectionAttribute objectValue = new CIP4.Simple.CIP4CassandraConnectionAttribute();
                objectValue.Keyspace = StringValue(element.Element(XName.Get("Keyspace", Globals.cioNS)), objectValue.Keyspace);
                objectValue.ColumnFamily = StringValue(element.Element(XName.Get("ColumnFamily", Globals.cioNS)), objectValue.ColumnFamily);
 
;

            return (CIP4.Simple.CIP4CassandraConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4CassandraConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4CassandraConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4CassandraConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4CassandraConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4CassandraConnectionAttribute objectValue = new CIP4.Simple.CIP4CassandraConnectionAttribute();

            if (Values.ContainsKey("Keyspace"))
                objectValue.Keyspace = StringValue(Values["Keyspace"].ToString(), objectValue.Keyspace);
            else
                objectValue.Keyspace = previousVersion.Keyspace;
            if (Values.ContainsKey("ColumnFamily"))
                objectValue.ColumnFamily = StringValue(Values["ColumnFamily"].ToString(), objectValue.ColumnFamily);
            else
                objectValue.ColumnFamily = previousVersion.ColumnFamily; 
;

            return (CIP4.Simple.CIP4CassandraConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4CassandraConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4CassandraConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4CassandraConnectionAttribute> list = new List<CIP4.Simple.CIP4CassandraConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4CassandraConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4CassandraConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4CassandraConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4CassandraConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.ColumnFamily != default(System.String))
            {
                xwrtr.WriteStartElement("ColumnFamily");
                xwrtr.WriteElementString("String", value.ColumnFamily);
                xwrtr.WriteEndElement();
            }

            if (value.Keyspace != default(System.String))
            {
                xwrtr.WriteStartElement("Keyspace");
                xwrtr.WriteElementString("String", value.Keyspace);
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4CassandraConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4CassandraConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4CassandraConnectionAttribute x, CIP4.Simple.CIP4CassandraConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4CassandraConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4MongoDBConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4MongoDBConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "Database":
                    return item.Database;
                case "Port":
                    return item.Port;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;
                case "Server":
                    return item.Server;
                case "Timeout":
                    return item.Timeout;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4MongoDBConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4MongoDBConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4MongoDBConnectionAttribute")
                return null;


            CIP4.Simple.CIP4MongoDBConnectionAttribute objectValue = new CIP4.Simple.CIP4MongoDBConnectionAttribute();
                objectValue.Server = StringValue(element.Element(XName.Get("Server", Globals.cioNS)), objectValue.Server);
                objectValue.Port = Int32Value(element.Element(XName.Get("Port", Globals.cioNS)), objectValue.Port);
                objectValue.Database = StringValue(element.Element(XName.Get("Database", Globals.cioNS)), objectValue.Database);
                objectValue.Timeout = Int32Value(element.Element(XName.Get("Timeout", Globals.cioNS)), objectValue.Timeout);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4MongoDBConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MongoDBConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4MongoDBConnectionAttribute objectValue = new CIP4.Simple.CIP4MongoDBConnectionAttribute();
                objectValue.Server = StringValue(element.Element(XName.Get("Server", Globals.cioNS)), objectValue.Server);
                objectValue.Port = Int32Value(element.Element(XName.Get("Port", Globals.cioNS)), objectValue.Port);
                objectValue.Database = StringValue(element.Element(XName.Get("Database", Globals.cioNS)), objectValue.Database);
                objectValue.Timeout = Int32Value(element.Element(XName.Get("Timeout", Globals.cioNS)), objectValue.Timeout);
 
;

            return (CIP4.Simple.CIP4MongoDBConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MongoDBConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MongoDBConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4MongoDBConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MongoDBConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4MongoDBConnectionAttribute objectValue = new CIP4.Simple.CIP4MongoDBConnectionAttribute();

            if (Values.ContainsKey("Server"))
                objectValue.Server = StringValue(Values["Server"].ToString(), objectValue.Server);
            else
                objectValue.Server = previousVersion.Server;
            if (Values.ContainsKey("Port"))
                objectValue.Port = Int32Value(Values["Port"].ToString(), objectValue.Port);
            else
                objectValue.Port = previousVersion.Port;
            if (Values.ContainsKey("Database"))
                objectValue.Database = StringValue(Values["Database"].ToString(), objectValue.Database);
            else
                objectValue.Database = previousVersion.Database;
            if (Values.ContainsKey("Timeout"))
                objectValue.Timeout = Int32Value(Values["Timeout"].ToString(), objectValue.Timeout);
            else
                objectValue.Timeout = previousVersion.Timeout; 
;

            return (CIP4.Simple.CIP4MongoDBConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4MongoDBConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4MongoDBConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4MongoDBConnectionAttribute> list = new List<CIP4.Simple.CIP4MongoDBConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4MongoDBConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4MongoDBConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4MongoDBConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4MongoDBConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.Database != default(System.String))
            {
                xwrtr.WriteStartElement("Database");
                xwrtr.WriteElementString("String", value.Database);
                xwrtr.WriteEndElement();
            }

            if (value.Port != default(System.Int32))
            {
                xwrtr.WriteStartElement("Port");
                xwrtr.WriteElementString("Int32", value.Port.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.Server != default(System.String))
            {
                xwrtr.WriteStartElement("Server");
                xwrtr.WriteElementString("String", value.Server);
                xwrtr.WriteEndElement();
            }

            if (value.Timeout != default(System.Int32))
            {
                xwrtr.WriteStartElement("Timeout");
                xwrtr.WriteElementString("Int32", value.Timeout.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4MongoDBConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4MongoDBConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4MongoDBConnectionAttribute x, CIP4.Simple.CIP4MongoDBConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4MongoDBConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4MigratorConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4MigratorConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4MigratorConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4MigratorConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4MigratorConnectionAttribute")
                return null;


            CIP4.Simple.CIP4MigratorConnectionAttribute objectValue = new CIP4.Simple.CIP4MigratorConnectionAttribute();
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4MigratorConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MigratorConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4MigratorConnectionAttribute objectValue = new CIP4.Simple.CIP4MigratorConnectionAttribute();
 
;

            return (CIP4.Simple.CIP4MigratorConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MigratorConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MigratorConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4MigratorConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MigratorConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4MigratorConnectionAttribute objectValue = new CIP4.Simple.CIP4MigratorConnectionAttribute();
 
;

            return (CIP4.Simple.CIP4MigratorConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4MigratorConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4MigratorConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4MigratorConnectionAttribute> list = new List<CIP4.Simple.CIP4MigratorConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4MigratorConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4MigratorConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4MigratorConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4MigratorConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4MigratorConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4MigratorConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4MigratorConnectionAttribute x, CIP4.Simple.CIP4MigratorConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4MigratorConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4MultiThreadConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4MultiThreadConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "NumberOfThreads":
                    return item.NumberOfThreads;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4MultiThreadConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4MultiThreadConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4MultiThreadConnectionAttribute")
                return null;


            CIP4.Simple.CIP4MultiThreadConnectionAttribute objectValue = new CIP4.Simple.CIP4MultiThreadConnectionAttribute();
                objectValue.NumberOfThreads = Int32Value(element.Element(XName.Get("NumberOfThreads", Globals.cioNS)), objectValue.NumberOfThreads);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4MultiThreadConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MultiThreadConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4MultiThreadConnectionAttribute objectValue = new CIP4.Simple.CIP4MultiThreadConnectionAttribute();
                objectValue.NumberOfThreads = Int32Value(element.Element(XName.Get("NumberOfThreads", Globals.cioNS)), objectValue.NumberOfThreads);
 
;

            return (CIP4.Simple.CIP4MultiThreadConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MultiThreadConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MultiThreadConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4MultiThreadConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MultiThreadConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4MultiThreadConnectionAttribute objectValue = new CIP4.Simple.CIP4MultiThreadConnectionAttribute();

            if (Values.ContainsKey("NumberOfThreads"))
                objectValue.NumberOfThreads = Int32Value(Values["NumberOfThreads"].ToString(), objectValue.NumberOfThreads);
            else
                objectValue.NumberOfThreads = previousVersion.NumberOfThreads; 
;

            return (CIP4.Simple.CIP4MultiThreadConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4MultiThreadConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4MultiThreadConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4MultiThreadConnectionAttribute> list = new List<CIP4.Simple.CIP4MultiThreadConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4MultiThreadConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4MultiThreadConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4MultiThreadConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4MultiThreadConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.NumberOfThreads != default(System.Int32))
            {
                xwrtr.WriteStartElement("NumberOfThreads");
                xwrtr.WriteElementString("Int32", value.NumberOfThreads.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4MultiThreadConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4MultiThreadConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4MultiThreadConnectionAttribute x, CIP4.Simple.CIP4MultiThreadConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4MultiThreadConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4MassTransitConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4MassTransitConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "BusId":
                    return item.BusId;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;
                case "TimeOutInMilliSecs":
                    return item.TimeOutInMilliSecs;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4MassTransitConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4MassTransitConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4MassTransitConnectionAttribute")
                return null;


            CIP4.Simple.CIP4MassTransitConnectionAttribute objectValue = new CIP4.Simple.CIP4MassTransitConnectionAttribute();
                objectValue.TimeOutInMilliSecs = Int32Value(element.Element(XName.Get("TimeOutInMilliSecs", Globals.cioNS)), objectValue.TimeOutInMilliSecs);
                objectValue.BusId = StringValue(element.Element(XName.Get("BusId", Globals.cioNS)), objectValue.BusId);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4MassTransitConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MassTransitConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4MassTransitConnectionAttribute objectValue = new CIP4.Simple.CIP4MassTransitConnectionAttribute();
                objectValue.TimeOutInMilliSecs = Int32Value(element.Element(XName.Get("TimeOutInMilliSecs", Globals.cioNS)), objectValue.TimeOutInMilliSecs);
                objectValue.BusId = StringValue(element.Element(XName.Get("BusId", Globals.cioNS)), objectValue.BusId);
 
;

            return (CIP4.Simple.CIP4MassTransitConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MassTransitConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MassTransitConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4MassTransitConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MassTransitConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4MassTransitConnectionAttribute objectValue = new CIP4.Simple.CIP4MassTransitConnectionAttribute();

            if (Values.ContainsKey("TimeOutInMilliSecs"))
                objectValue.TimeOutInMilliSecs = Int32Value(Values["TimeOutInMilliSecs"].ToString(), objectValue.TimeOutInMilliSecs);
            else
                objectValue.TimeOutInMilliSecs = previousVersion.TimeOutInMilliSecs;
            if (Values.ContainsKey("BusId"))
                objectValue.BusId = StringValue(Values["BusId"].ToString(), objectValue.BusId);
            else
                objectValue.BusId = previousVersion.BusId; 
;

            return (CIP4.Simple.CIP4MassTransitConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4MassTransitConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4MassTransitConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4MassTransitConnectionAttribute> list = new List<CIP4.Simple.CIP4MassTransitConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4MassTransitConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4MassTransitConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4MassTransitConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4MassTransitConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.BusId != default(System.String))
            {
                xwrtr.WriteStartElement("BusId");
                xwrtr.WriteElementString("String", value.BusId);
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.TimeOutInMilliSecs != default(System.Int32))
            {
                xwrtr.WriteStartElement("TimeOutInMilliSecs");
                xwrtr.WriteElementString("Int32", value.TimeOutInMilliSecs.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4MassTransitConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4MassTransitConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4MassTransitConnectionAttribute x, CIP4.Simple.CIP4MassTransitConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4MassTransitConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4SliceConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4SliceConnectionAttribute item)
        {
            if (item == null)
                return null;

            if (item is CIP4.Simple.CIP4GenericSliceConnectionAttribute)
                return CIP4GenericSliceConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4GenericSliceConnectionAttribute)item);
            if (item is CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)
                return CIP4MongoDBSliceConnectionAttribute_Serializer.GetValueForPath(path, index, (CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)item);

            switch (path[index])
            {
                case "Basket":
                    return item.Basket;
                case "BasketIndex":
                    return item.BasketIndex;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4SliceConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4SliceConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName == "CIP4GenericSliceConnectionAttribute")
                return CIP4GenericSliceConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName == "CIP4MongoDBSliceConnectionAttribute")
                return CIP4MongoDBSliceConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element, StreamSeeds, propertyPath, null);
            if (element.Name.LocalName != "CIP4SliceConnectionAttribute")
                return null;


            CIP4.Simple.CIP4SliceConnectionAttribute objectValue = new CIP4.Simple.CIP4SliceConnectionAttribute();
                objectValue.Basket = StringValue(element.Element(XName.Get("Basket", Globals.cioNS)), objectValue.Basket);
                objectValue.BasketIndex = StringValue(element.Element(XName.Get("BasketIndex", Globals.cioNS)), objectValue.BasketIndex);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4SliceConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4SliceConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4SliceConnectionAttribute objectValue = new CIP4.Simple.CIP4SliceConnectionAttribute();
                objectValue.Basket = StringValue(element.Element(XName.Get("Basket", Globals.cioNS)), objectValue.Basket);
                objectValue.BasketIndex = StringValue(element.Element(XName.Get("BasketIndex", Globals.cioNS)), objectValue.BasketIndex);
 
;

            return (CIP4.Simple.CIP4SliceConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4SliceConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4SliceConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4SliceConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4SliceConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4SliceConnectionAttribute objectValue = new CIP4.Simple.CIP4SliceConnectionAttribute();

            if (Values.ContainsKey("Basket"))
                objectValue.Basket = StringValue(Values["Basket"].ToString(), objectValue.Basket);
            else
                objectValue.Basket = previousVersion.Basket;
            if (Values.ContainsKey("BasketIndex"))
                objectValue.BasketIndex = StringValue(Values["BasketIndex"].ToString(), objectValue.BasketIndex);
            else
                objectValue.BasketIndex = previousVersion.BasketIndex; 
;

            return (CIP4.Simple.CIP4SliceConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4SliceConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4SliceConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4SliceConnectionAttribute> list = new List<CIP4.Simple.CIP4SliceConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4SliceConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4SliceConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4SliceConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {
            if (value is CIP4.Simple.CIP4GenericSliceConnectionAttribute)
            {
                CIP4GenericSliceConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4GenericSliceConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }
            if (value is CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)
            {
                CIP4MongoDBSliceConnectionAttribute_Serializer.Serialize((CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)value, keyValue, xwrtr, StreamSeeds, propertyPath, serializerWrapper, doVersioning);
                return;
            }

            xwrtr.WriteStartElement("CIP4SliceConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.Basket != default(System.String))
            {
                xwrtr.WriteStartElement("Basket");
                xwrtr.WriteElementString("String", value.Basket);
                xwrtr.WriteEndElement();
            }

            if (value.BasketIndex != default(System.String))
            {
                xwrtr.WriteStartElement("BasketIndex");
                xwrtr.WriteElementString("String", value.BasketIndex);
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4SliceConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4SliceConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4SliceConnectionAttribute x, CIP4.Simple.CIP4SliceConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4SliceConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4GenericSliceConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4GenericSliceConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "Basket":
                    return item.Basket;
                case "BasketIndex":
                    return item.BasketIndex;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4GenericSliceConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4GenericSliceConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4GenericSliceConnectionAttribute")
                return null;


            CIP4.Simple.CIP4GenericSliceConnectionAttribute objectValue = new CIP4.Simple.CIP4GenericSliceConnectionAttribute();
                objectValue.Basket = StringValue(element.Element(XName.Get("Basket", Globals.cioNS)), objectValue.Basket);
                objectValue.BasketIndex = StringValue(element.Element(XName.Get("BasketIndex", Globals.cioNS)), objectValue.BasketIndex);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4GenericSliceConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4GenericSliceConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4GenericSliceConnectionAttribute objectValue = new CIP4.Simple.CIP4GenericSliceConnectionAttribute();
                objectValue.Basket = StringValue(element.Element(XName.Get("Basket", Globals.cioNS)), objectValue.Basket);
                objectValue.BasketIndex = StringValue(element.Element(XName.Get("BasketIndex", Globals.cioNS)), objectValue.BasketIndex);
 
;

            return (CIP4.Simple.CIP4GenericSliceConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4GenericSliceConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4GenericSliceConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4GenericSliceConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4GenericSliceConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4GenericSliceConnectionAttribute objectValue = new CIP4.Simple.CIP4GenericSliceConnectionAttribute();

            if (Values.ContainsKey("Basket"))
                objectValue.Basket = StringValue(Values["Basket"].ToString(), objectValue.Basket);
            else
                objectValue.Basket = previousVersion.Basket;
            if (Values.ContainsKey("BasketIndex"))
                objectValue.BasketIndex = StringValue(Values["BasketIndex"].ToString(), objectValue.BasketIndex);
            else
                objectValue.BasketIndex = previousVersion.BasketIndex; 
;

            return (CIP4.Simple.CIP4GenericSliceConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4GenericSliceConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4GenericSliceConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4GenericSliceConnectionAttribute> list = new List<CIP4.Simple.CIP4GenericSliceConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4GenericSliceConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4GenericSliceConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4GenericSliceConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4GenericSliceConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.Basket != default(System.String))
            {
                xwrtr.WriteStartElement("Basket");
                xwrtr.WriteElementString("String", value.Basket);
                xwrtr.WriteEndElement();
            }

            if (value.BasketIndex != default(System.String))
            {
                xwrtr.WriteStartElement("BasketIndex");
                xwrtr.WriteElementString("String", value.BasketIndex);
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4GenericSliceConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4GenericSliceConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4GenericSliceConnectionAttribute x, CIP4.Simple.CIP4GenericSliceConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4GenericSliceConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4MongoDBSliceConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4MongoDBSliceConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "Basket":
                    return item.Basket;
                case "BasketIndex":
                    return item.BasketIndex;
                case "Database":
                    return item.Database;
                case "Port":
                    return item.Port;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;
                case "Server":
                    return item.Server;
                case "Timeout":
                    return item.Timeout;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4MongoDBSliceConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4MongoDBSliceConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4MongoDBSliceConnectionAttribute")
                return null;


            CIP4.Simple.CIP4MongoDBSliceConnectionAttribute objectValue = new CIP4.Simple.CIP4MongoDBSliceConnectionAttribute();
                objectValue.Server = StringValue(element.Element(XName.Get("Server", Globals.cioNS)), objectValue.Server);
                objectValue.Port = Int32Value(element.Element(XName.Get("Port", Globals.cioNS)), objectValue.Port);
                objectValue.Database = StringValue(element.Element(XName.Get("Database", Globals.cioNS)), objectValue.Database);
                objectValue.Timeout = Int32Value(element.Element(XName.Get("Timeout", Globals.cioNS)), objectValue.Timeout);
                objectValue.Basket = StringValue(element.Element(XName.Get("Basket", Globals.cioNS)), objectValue.Basket);
                objectValue.BasketIndex = StringValue(element.Element(XName.Get("BasketIndex", Globals.cioNS)), objectValue.BasketIndex);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MongoDBSliceConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4MongoDBSliceConnectionAttribute objectValue = new CIP4.Simple.CIP4MongoDBSliceConnectionAttribute();
                objectValue.Server = StringValue(element.Element(XName.Get("Server", Globals.cioNS)), objectValue.Server);
                objectValue.Port = Int32Value(element.Element(XName.Get("Port", Globals.cioNS)), objectValue.Port);
                objectValue.Database = StringValue(element.Element(XName.Get("Database", Globals.cioNS)), objectValue.Database);
                objectValue.Timeout = Int32Value(element.Element(XName.Get("Timeout", Globals.cioNS)), objectValue.Timeout);
                objectValue.Basket = StringValue(element.Element(XName.Get("Basket", Globals.cioNS)), objectValue.Basket);
                objectValue.BasketIndex = StringValue(element.Element(XName.Get("BasketIndex", Globals.cioNS)), objectValue.BasketIndex);
 
;

            return (CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4MongoDBSliceConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MongoDBSliceConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4MongoDBSliceConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4MongoDBSliceConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4MongoDBSliceConnectionAttribute objectValue = new CIP4.Simple.CIP4MongoDBSliceConnectionAttribute();

            if (Values.ContainsKey("Server"))
                objectValue.Server = StringValue(Values["Server"].ToString(), objectValue.Server);
            else
                objectValue.Server = previousVersion.Server;
            if (Values.ContainsKey("Port"))
                objectValue.Port = Int32Value(Values["Port"].ToString(), objectValue.Port);
            else
                objectValue.Port = previousVersion.Port;
            if (Values.ContainsKey("Database"))
                objectValue.Database = StringValue(Values["Database"].ToString(), objectValue.Database);
            else
                objectValue.Database = previousVersion.Database;
            if (Values.ContainsKey("Timeout"))
                objectValue.Timeout = Int32Value(Values["Timeout"].ToString(), objectValue.Timeout);
            else
                objectValue.Timeout = previousVersion.Timeout;
            if (Values.ContainsKey("Basket"))
                objectValue.Basket = StringValue(Values["Basket"].ToString(), objectValue.Basket);
            else
                objectValue.Basket = previousVersion.Basket;
            if (Values.ContainsKey("BasketIndex"))
                objectValue.BasketIndex = StringValue(Values["BasketIndex"].ToString(), objectValue.BasketIndex);
            else
                objectValue.BasketIndex = previousVersion.BasketIndex; 
;

            return (CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4MongoDBSliceConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4MongoDBSliceConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4MongoDBSliceConnectionAttribute> list = new List<CIP4.Simple.CIP4MongoDBSliceConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4MongoDBSliceConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4MongoDBSliceConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4MongoDBSliceConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4MongoDBSliceConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.Basket != default(System.String))
            {
                xwrtr.WriteStartElement("Basket");
                xwrtr.WriteElementString("String", value.Basket);
                xwrtr.WriteEndElement();
            }

            if (value.BasketIndex != default(System.String))
            {
                xwrtr.WriteStartElement("BasketIndex");
                xwrtr.WriteElementString("String", value.BasketIndex);
                xwrtr.WriteEndElement();
            }

            if (value.Database != default(System.String))
            {
                xwrtr.WriteStartElement("Database");
                xwrtr.WriteElementString("String", value.Database);
                xwrtr.WriteEndElement();
            }

            if (value.Port != default(System.Int32))
            {
                xwrtr.WriteStartElement("Port");
                xwrtr.WriteElementString("Int32", value.Port.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.Server != default(System.String))
            {
                xwrtr.WriteStartElement("Server");
                xwrtr.WriteElementString("String", value.Server);
                xwrtr.WriteEndElement();
            }

            if (value.Timeout != default(System.Int32))
            {
                xwrtr.WriteStartElement("Timeout");
                xwrtr.WriteElementString("Int32", value.Timeout.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4MongoDBSliceConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4MongoDBSliceConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4MongoDBSliceConnectionAttribute x, CIP4.Simple.CIP4MongoDBSliceConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4MongoDBSliceConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class CIP4TemplateConnectionAttribute_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.CIP4TemplateConnectionAttribute item)
        {
            if (item == null)
                return null;


            switch (path[index])
            {
                case "Connection":
                    return item.Connection;
                case "ProviderKind":
                    return item.ProviderKind;
                case "SerializerKind":
                    return item.SerializerKind;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static CIP4.Simple.CIP4TemplateConnectionAttribute DeSerialize(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.CIP4TemplateConnectionAttribute defaultValue)
        {
            if (element == null)
                return defaultValue;

            // XElement itemElement = null;

            if (element.Name.LocalName != "CIP4TemplateConnectionAttribute")
                return null;


            CIP4.Simple.CIP4TemplateConnectionAttribute objectValue = new CIP4.Simple.CIP4TemplateConnectionAttribute();
                objectValue.Connection = StringValue(element.Element(XName.Get("Connection", Globals.cioNS)), objectValue.Connection);
 
;

     
            // no version handling for this type           
            return (CIP4.Simple.CIP4TemplateConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4TemplateConnectionAttribute SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.CIP4TemplateConnectionAttribute objectValue = new CIP4.Simple.CIP4TemplateConnectionAttribute();
                objectValue.Connection = StringValue(element.Element(XName.Get("Connection", Globals.cioNS)), objectValue.Connection);
 
;

            return (CIP4.Simple.CIP4TemplateConnectionAttribute)objectValue;
        }

        public static CIP4.Simple.CIP4TemplateConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4TemplateConnectionAttribute previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.CIP4TemplateConnectionAttribute GetItemVersion(long versionTimestamp, CIP4.Simple.CIP4TemplateConnectionAttribute  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.CIP4TemplateConnectionAttribute objectValue = new CIP4.Simple.CIP4TemplateConnectionAttribute();

            if (Values.ContainsKey("Connection"))
                objectValue.Connection = StringValue(Values["Connection"].ToString(), objectValue.Connection);
            else
                objectValue.Connection = previousVersion.Connection; 
;

            return (CIP4.Simple.CIP4TemplateConnectionAttribute)objectValue;
        }

        internal static List<CIP4.Simple.CIP4TemplateConnectionAttribute> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.CIP4TemplateConnectionAttribute> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.CIP4TemplateConnectionAttribute> list = new List<CIP4.Simple.CIP4TemplateConnectionAttribute>();
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath, null));
            return dictionary;
        }

        public static string SerializeItem(CIP4.Simple.CIP4TemplateConnectionAttribute value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {

            // construct the dateTime from ticks so it doesn't add the offset on the end
            DateTime modifiedDate = new DateTime(DateTime.Now.Ticks);

            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.CIP4TemplateConnectionAttribute", serializerWrapper, true);
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.CIP4TemplateConnectionAttribute value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("CIP4TemplateConnectionAttribute", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.Connection != default(System.String))
            {
                xwrtr.WriteStartElement("Connection");
                xwrtr.WriteElementString("String", value.Connection);
                xwrtr.WriteEndElement();
            }

            if (value.ProviderKind != default(CIP4.Simple.ProviderTypesEnum))
            {
                xwrtr.WriteStartElement("ProviderKind");
                xwrtr.WriteElementString("ProviderTypesEnum", value.ProviderKind.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.SerializerKind != default(CIP4.Common.SerializerKindEnum))
            {
                xwrtr.WriteStartElement("SerializerKind");
                xwrtr.WriteElementString("SerializerKindEnum", value.SerializerKind.ToString());
                xwrtr.WriteEndElement();
            }

 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.CIP4TemplateConnectionAttribute)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.CIP4TemplateConnectionAttribute>
        {
            public bool Equals(CIP4.Simple.CIP4TemplateConnectionAttribute x, CIP4.Simple.CIP4TemplateConnectionAttribute y)
            {
                return SerializeToXElement(x, null).ToString() == SerializeToXElement(y, null).ToString();
            }

            public int GetHashCode(CIP4.Simple.CIP4TemplateConnectionAttribute obj)
            {
                return SerializeToXElement(obj, null).ToString().GetHashCode();
            }
        }

    }
            
    public class ViewType_Serializer : CIP4_Simple_SerializerBaseType
    {

        private static List<KeyValuePair<string, int>> _Keys;
        public static IEnumerable<KeyValuePair<string, int>> GetKeys()
        {
            if (_Keys == null)
            {
                _Keys = new List<KeyValuePair<string, int>>
                {
                    new KeyValuePair<string, int>("ExternalID", 0),

                };
            }
            return _Keys;
        }


        public static object GetValueForPath(string[] path, int index, CIP4.Simple.ViewType item)
        {
            if (item == null)
                return null;
            if (index == 0)
                switch (path[0])
                {
                    case "ExternalID":
                        return GetExternalIDForObject(item);
                }



            switch (path[index])
            {
                case "AssemblyPath":
                    return item.AssemblyPath;
                case "BatchSize":
                    return item.BatchSize;
                case "CollectionName":
                    return item.CollectionName;
                case "CurrentTemplate":
                    return item.CurrentTemplate;
                case "CurrentType":
                    return item.CurrentType;
                case "DataConnection":
                    return CIP4.Serializer.CIP4ConnectionAttribute_Serializer.GetValueForPath(path, index + 1, item.DataConnection);
                case "ExternalID":
                    return item.ExternalID;

                default:
                    return null;
            }

            // Not required as all previous paths get us out of here
            // return null;
        }

        public static ExternalIDType GetExternalID(XElement itemElement)
        {
            XElement element = null;
            if (itemElement.Name == XName.Get("Item", Globals.ciiNS))
            {
                element = itemElement.LastElement();
            }
            else
                element = itemElement;
            List<object> parts = new List<object>();
            parts.Add(StringValue(element.Element(XName.Get("String", Globals.cioNS)), string.Empty));


            ExternalIDType result = ExternalIDType.ExternalIDFromParts(parts);

            if (result == null)
                return ExternalIDType.ExternalIDFromEscapedString(StringValue(itemElement.Element(XName.Get("ExternalID", Globals.ciiNS)), string.Empty));

            return result;
        }
        public static ExternalIDType GetExternalIDForObject(CIP4.Simple.ViewType value)
        {
            List<object> parts = new List<object>();
            parts.Add(value.ExternalID);

            return ExternalIDType.ExternalIDFromParts(parts);
        }

        public static CIP4.Simple.ViewType DeSerialize(DateTime versionTimestamp, object itemData, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {
            return DeSerialize(versionTimestamp, itemData, StreamSeeds, propertyPath, null);
        }
        public static CIP4.Simple.ViewType DeSerialize(DateTime versionTimestamp, object itemData, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, CIP4.Simple.ViewType defaultValue)
        {
            XElement itemElement = GetXmlData(itemData);
            if (itemElement == null)
                return defaultValue;
            XElement element = null;
            if (itemElement.Name == XName.Get("Item", Globals.ciiNS))
            {
                element = itemElement.LastElement();
                propertyPath = "CIP4.Simple.ViewType";
            }
            else
                element = itemElement;


            if (element.Name.LocalName != "ViewType")
                return null;


            CIP4.Simple.ViewType objectValue = SetProperties(versionTimestamp, itemElement, element, StreamSeeds, propertyPath);
    

            // no version handling for this type
            return objectValue == null? defaultValue : (CIP4.Simple.ViewType)objectValue;
        }

        public static CIP4.Simple.ViewType SetProperties(DateTime versionTimestamp, XElement itemElement, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath)
        {


            CIP4.Simple.ViewType objectValue = new CIP4.Simple.ViewType();
                objectValue.AssemblyPath = StringValue(element.Element(XName.Get("AssemblyPath", Globals.cioNS)), objectValue.AssemblyPath);
                objectValue.DataConnection = CIP4.Serializer.CIP4ConnectionAttribute_Serializer.DeSerialize(versionTimestamp, element.Element(XName.Get("DataConnection", Globals.cioNS)).FirstElement(), StreamSeeds, propertyPath + ".DataConnection", objectValue.DataConnection);
                objectValue.CurrentType = StringValue(element.Element(XName.Get("CurrentType", Globals.cioNS)), objectValue.CurrentType);
                objectValue.CollectionName = StringValue(element.Element(XName.Get("CollectionName", Globals.cioNS)), objectValue.CollectionName);
                objectValue.BatchSize = Int32Value(element.Element(XName.Get("BatchSize", Globals.cioNS)), objectValue.BatchSize);
                objectValue.CurrentTemplate = StringValue(element.Element(XName.Get("CurrentTemplate", Globals.cioNS)), objectValue.CurrentTemplate);
 
;

            return (CIP4.Simple.ViewType)objectValue;
        }

        public static CIP4.Simple.ViewType GetItemVersion(long versionTimestamp, CIP4.Simple.ViewType previousVersion)
        {
            return previousVersion;
        }

        public static CIP4.Simple.ViewType GetItemVersion(long versionTimestamp, CIP4.Simple.ViewType  previousVersion, Dictionary<string, object> Values)
        {

            CIP4.Simple.ViewType objectValue = new CIP4.Simple.ViewType();

            if (Values.ContainsKey("AssemblyPath"))
                objectValue.AssemblyPath = StringValue(Values["AssemblyPath"].ToString(), objectValue.AssemblyPath);
            else
                objectValue.AssemblyPath = previousVersion.AssemblyPath;
            if (Values.ContainsKey("CurrentType"))
                objectValue.CurrentType = StringValue(Values["CurrentType"].ToString(), objectValue.CurrentType);
            else
                objectValue.CurrentType = previousVersion.CurrentType;
            if (Values.ContainsKey("CollectionName"))
                objectValue.CollectionName = StringValue(Values["CollectionName"].ToString(), objectValue.CollectionName);
            else
                objectValue.CollectionName = previousVersion.CollectionName;
            if (Values.ContainsKey("BatchSize"))
                objectValue.BatchSize = Int32Value(Values["BatchSize"].ToString(), objectValue.BatchSize);
            else
                objectValue.BatchSize = previousVersion.BatchSize;
            if (Values.ContainsKey("CurrentTemplate"))
                objectValue.CurrentTemplate = StringValue(Values["CurrentTemplate"].ToString(), objectValue.CurrentTemplate);
            else
                objectValue.CurrentTemplate = previousVersion.CurrentTemplate; 
;

            return (CIP4.Simple.ViewType)objectValue;
        }


        internal static List<CIP4.Simple.ViewType> DeSerializeList(DateTime versionTimestamp, XElement element, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, List<CIP4.Simple.ViewType> defaultValue)
        {
            if (element == null)
                return defaultValue;
            List<CIP4.Simple.ViewType> list = new List<CIP4.Simple.ViewType>();
            int index = 0;
            foreach (XElement valueElement in element.Elements())
                list.Add(DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath + "[" + (index++).ToString() + "]", null));
            return list;
        }

        public static System.Collections.IDictionary DeSerializeDictionary(DateTime versionTimestamp, XElement element, GetDictionaryDelegate getDictionary, GetKeyDelegate getKey, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, System.Collections.IDictionary defaultValue)
        {
            if (element == null)
                return defaultValue;
            System.Collections.IDictionary dictionary = getDictionary();
            foreach (XElement valueElement in element.Elements())
                dictionary.Add(getKey(valueElement.Attribute("Key").Value), DeSerialize(versionTimestamp, valueElement, StreamSeeds, propertyPath + "[" + getKey(valueElement.Attribute("Key").Value) + "]", null));
            return dictionary;
        }

        public static List<CIP4ReferenceType<CIP4.Simple.ViewType>> DeSerializeReferenceList(XElement element)
        {
            if (element == null)
                return null;
            List<CIP4ReferenceType<CIP4.Simple.ViewType>> list = new List<CIP4ReferenceType<CIP4.Simple.ViewType>>();
            foreach (XElement valueElement in element.Elements())
            {
                CIP4ReferenceType<CIP4.Simple.ViewType> refValue = new CIP4ReferenceType<CIP4.Simple.ViewType>();
                refValue.TargetExternalID = GetExternalIdFromReferenceElement(valueElement);
                list.Add(refValue);
            }
            return list;
        }

        public static CIP4ReferenceType<CIP4.Simple.ViewType> MakeCIP4Reference(XElement element, CIP4ReferenceType<CIP4.Simple.ViewType> defaultValue)
        {
            string externalID = GetExternalIdFromReferenceElement(element);
            if (!string.IsNullOrEmpty(externalID))
                return new CIP4ReferenceType<CIP4.Simple.ViewType> { TargetExternalID = externalID };
            else
                return defaultValue;
        }

        public static string SerializeItem(CIP4.Simple.ViewType value, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, ISerializerType serializerWrapper)
        {



            StringWriter swrtr = new StringWriter();
            XmlTextWriter xwrtr = new XmlTextWriter(swrtr);
            // write header
            xwrtr.WriteStartElement("Item", Globals.ciiNS);
            xwrtr.WriteElementString("Valid", "1");
            xwrtr.WriteElementString("ItemStatus", "100");
            xwrtr.WriteElementString("ExternalID", GetExternalIDForObject(value).ToString());
            Serialize(value, null, xwrtr, StreamSeeds, "CIP4.Simple.ViewType", serializerWrapper, true);
            xwrtr.WriteEndElement();
            return swrtr.ToString();
        }

        internal static void Serialize(CIP4.Simple.ViewType value, string keyValue, XmlTextWriter xwrtr, Dictionary<string, KeyValuePair<PropertyInfo, object>> StreamSeeds, string propertyPath, ISerializerType serializerWrapper, bool doVersioning)
        {

            xwrtr.WriteStartElement("ViewType", Globals.cioNS);
            if (!string.IsNullOrEmpty(keyValue))
                xwrtr.WriteAttributeString("Key", keyValue);
            if (value.AssemblyPath != default(System.String))
            {
                xwrtr.WriteStartElement("AssemblyPath");
                xwrtr.WriteElementString("String", value.AssemblyPath);
                xwrtr.WriteEndElement();
            }

            if (value.BatchSize != default(System.Int32))
            {
                xwrtr.WriteStartElement("BatchSize");
                xwrtr.WriteElementString("Int32", value.BatchSize.ToString());
                xwrtr.WriteEndElement();
            }

            if (value.CollectionName != default(System.String))
            {
                xwrtr.WriteStartElement("CollectionName");
                xwrtr.WriteElementString("String", value.CollectionName);
                xwrtr.WriteEndElement();
            }

            if (value.CurrentTemplate != default(System.String))
            {
                xwrtr.WriteStartElement("CurrentTemplate");
                xwrtr.WriteElementString("String", value.CurrentTemplate);
                xwrtr.WriteEndElement();
            }

            if (value.CurrentType != default(System.String))
            {
                xwrtr.WriteStartElement("CurrentType");
                xwrtr.WriteElementString("String", value.CurrentType);
                xwrtr.WriteEndElement();
            }

            if (value.DataConnection != null)
            {
                xwrtr.WriteStartElement("DataConnection");
                CIP4ConnectionAttribute_Serializer.Serialize(value.DataConnection, null, xwrtr, StreamSeeds, propertyPath + ".DataConnection", serializerWrapper, doVersioning);
                xwrtr.WriteEndElement();
            }
 
            xwrtr.WriteEndElement();
        }

        public static object SerializeToXElement(object value, ISerializerType serializerWrapper)
        {
            StringWriter vswrtr = new StringWriter();
            XmlTextWriter vxwrtr = new XmlTextWriter(vswrtr);
            Serialize((CIP4.Simple.ViewType)value, null, vxwrtr, null, null, serializerWrapper, false);
            XElement velement = XElement.Parse(vswrtr.ToString());
            return velement;
        }


        public class EqualityComparer : IEqualityComparer<CIP4.Simple.ViewType>
        {
            public bool Equals(CIP4.Simple.ViewType x, CIP4.Simple.ViewType y)
            {
                return GetExternalIDForObject(x).ToString() == GetExternalIDForObject(y).ToString();
            }

            public int GetHashCode(CIP4.Simple.ViewType obj)
            {
                return GetExternalIDForObject(obj).ToString().GetHashCode();
            }
        }

    }


}

